A lightweight SQLite adapter for ElizaOS that provides persistent storage with vector embedding support, relationship management, and caching capabilities. Designed for embedded applications and local development.
- Vector embedding storage with BLOB support
- JSON storage with validation
- Comprehensive schema for agents, rooms, and participants
- Relationship management system
- Memory and goal tracking
- Built-in caching system
- Foreign key constraints
- Automatic timestamp management
pnpm add @elizaos/adapter-sqlite
- id (TEXT PRIMARY KEY)
- name (TEXT)
- username (TEXT)
- email (TEXT)
- avatarUrl (TEXT)
- details (JSON)
- id (TEXT PRIMARY KEY)
- type (TEXT)
- content (TEXT)
- embedding (BLOB)
- userId (TEXT FK)
- roomId (TEXT FK)
- agentId (TEXT FK)
- id (TEXT PRIMARY KEY)
- name (TEXT)
- status (TEXT)
- description (TEXT)
- objectives (JSON)
- participants (user-room relationships)
- relationships (user-user connections)
- rooms (conversation spaces)
import { SqliteDatabaseAdapter } from '@elizaos/adapter-sqlite';
const adapter = new SqliteDatabaseAdapter('path/to/database.db');
await adapter.init();
// Get room by ID
const room = await adapter.getRoom(roomId);
// Get participants in a room
const participants = await adapter.getParticipantsForRoom(roomId);
// Get participant state
const state = await adapter.getParticipantUserState(roomId, userId);
// Set participant state
await adapter.setParticipantUserState(roomId, userId, 'FOLLOWED');
// Get all participants for an account
const participants = await adapter.getParticipantsForAccount(userId);
// Store a memory with embedding
await adapter.createMemory({
type: 'conversation',
content: 'Memory content',
embedding: new Float32Array([...]),
userId,
roomId
});
// Create a new goal
await adapter.createGoal({
name: 'Complete task',
status: 'IN_PROGRESS',
objectives: ['Research', 'Implementation'],
userId,
roomId
});
- Automatic JSON validation for fields like
details
,objectives
, andvalue
- Enforced through SQLite CHECK constraints
- Optimized BLOB storage for embeddings
- Compatible with various embedding models
- Supports similarity search operations
- Automatic
createdAt
timestamps - Consistent datetime handling
- Uses prepared statements for efficient queries
- Implements proper indexing on frequently accessed columns
- Enforces data integrity through foreign key constraints
- Optimized blob storage for vector embeddings
- JSON validation at the database level
# Run tests
pnpm test
# Run tests in watch mode
pnpm test:watch
- Room management operations
- Participant state handling
- Account relationships
- Database initialization
- Connection management
- Always initialize the adapter before use
- Properly close the connection when done
- Use transactions for multiple related operations
- Handle potential JSON validation errors
- Consider embedding size limitations
- Implement proper error handling
- Node.js 23.3.0+
- SQLite 3.35.0+ (for JSON support)
- Sufficient disk space for vector storage
- ElizaOS core package